﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/Admin/_AdminLayout.cshtml";
}
@using PagedList.Mvc;
@using PagedList;

<div id="content" class="span10">
    <!-- content starts -->
    <div>
        <ul class="breadcrumb">
            <li>
                <a href="#">Home</a> <span class="divider">/</span>
            </li>
            <li>
                <a href="#">Danh sách đơn hàng</a>
            </li>
        </ul>
    </div>
    <div class="row-fluid sortable">
        <div class="box span12">
            <div class="box-content">
                <div class="row-fluid">
                    <div class="span12 form-inline">
                        @using (Html.BeginForm("ThemVaoGioHang", "AdminNhapHang", FormMethod.Post))
                        {
                            <div id="search-box" style="text-align: left">
                                <span class="error">@ViewBag.error</span>
                                <br />
                                <label>Mã sản phẩm</label><input type="text" name="masanpham" id="masanpham">
                                <label>Số lượng</label><input type="text" name="soluong" id="soluong" value="1" onkeyup="this.value=CheckValue(this.value)">
                                <label>Giá</label><input type="text" name="gianhap" id="gianhap" value="0" onkeyup="this.value=CheckValue(this.value)">
                                <input type="submit" value="Nhập" class="button4" />
                                <input type="submit" value="Nhập lại" class="button4" onclick="Reset()" />
                                <br />
                                <a href="~/adminsanpham/themmoi" target="_blank">Thêm mới</a>
                                <a href="~/adminsanpham/danhsach" target="_blank">Tra cứu danh sách</a>
                                <a href="~/adminnhaphang/luuphieunhap">Lưu</a>
                                <script>
                                    function CheckValue(value) {
                                        if (parseInt(value) < 1 || isNaN(value) || value==null)
                                            return 1;
                                        else return value;
                                    }
                                    function Reset() {
                                        $("#masanpham").val("");
                                        $("#soluong").val("");
                                        $("#gianhap").val("");
                                    }
                                    $(".radioBtn").click(function () {
                                        $("#in").attr("disabled", true);
                                        if ($("input[name=ynRadio]:checked").val() == "theongay") {
                                            $("#indate").attr("disabled", false);
                                            $("#from").attr("disabled", true);
                                            $("#to").attr("disabled", true);
                                        }
                                        if ($("input[name=ynRadio]:checked").val() == "range") {
                                            $("#indate").attr("disabled", true);
                                            $("#from").attr("disabled", false);
                                            $("#to").attr("disabled", false);
                                        }
                                    });
                                </script>
                            </div>
                        }
                    </div>

                </div>
            </div>
            <div class="clearfix"></div>
            <table class="table table-striped table-bordered bootstrap-datatable datatable">
                <thead>
                    <tr>
                        <th>id</th>
                        <th>Mã sản phẩm</th>
                        <th>Tên sản phẩm</th>
                        <th>Số lượng nhập</th>
                        <th>Giá nhập</th>
                        <th>Giá bán</th>
                        <th>Thành tiền</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    
                    @{BabyToys.Models.ViewModel.Cart cart = ViewBag.cart;}
                  
                    @if (cart != null)
                    {
                        foreach (var item in cart.ListItem)
                        {
                        <tr>
                            <td>@item.SanPham.IdSanPham</td>
                            <td>@item.SanPham.MaSP</td>
                            <td>@item.SanPham.TenSP</td>
                            <td>@item.SoLuong</td>
                            <td>Mở rộng</td>
                            <td>@item.Gia</td>
                            <td>@item.ThanhTien</td>
                            <td><a href="~/adminnhaphang/xoakhoigiohang/?idsanpham=@item.SanPham.IdSanPham">xóa</a></td>
                        </tr>
                        }
                    }
                </tbody>
            </table>

        </div>
    </div>
</div>


